<%@ Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" Theme="Default" 
    EnableTheming="true" CodeFile="ManageUsers.aspx.cs" Inherits="ManageUsers" 
    Title="Dr. Yurttas' Office Library &mdash; Manage Users" %>
<asp:Content ID="ContentAdmin" ContentPlaceHolderID="MasterContentAdmin" Runat="Server">
    <asp:LoginView ID="LoginViewAdmin" runat="server">
        <RoleGroups>
            <asp:RoleGroup Roles="admin">
                <ContentTemplate>
                    <div id="users-list">
                        <asp:GridView ID="UsersList" runat="server" DataSourceID="SqlDataSource1" 
                            AutoGenerateColumns="False" AutoGenerateEditButton="False" 
                            AutoGenerateDeleteButton="False" AllowSorting="True" DataKeyNames="myUserId" 
                            AllowPaging="True">
                            <Columns>
                                <asp:BoundField DataField="myUserId" HeaderText="myUserId" SortExpression="myUserId" 
                                    ReadOnly="True" InsertVisible="False" Visible="False" />
                                <asp:BoundField DataField="myRoleId" HeaderText="myRoleId" SortExpression="myRoleId" 
                                    ReadOnly="True" InsertVisible="False" Visible="False" />
                                <asp:BoundField DataField="UserName" HeaderText="Username" 
                                    SortExpression="UserName" />
                                <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
                                <asp:BoundField DataField="RoleName" HeaderText="Membership" 
                                    SortExpression="RoleName" />
                            </Columns>
                        </asp:GridView>
                        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:sylibUsers %>"
                            SelectCommand="SELECT vw_aspnet_MembershipUsers.UserId AS myUserId, Email, UserName,
                                vw_aspnet_UsersInRoles.RoleId AS myRoleId, RoleName, 
                                vw_aspnet_Roles.RoleId AS keyRoleId, vw_aspnet_UsersInRoles.UserId as keyUserId FROM
                                vw_aspnet_MembershipUsers, vw_aspnet_UsersInRoles, vw_aspnet_Roles WHERE
                                vw_aspnet_Roles.RoleId = vw_aspnet_UsersInRoles.RoleId AND
                                vw_aspnet_UsersInRoles.UserId = vw_aspnet_MembershipUsers.UserId">
                        </asp:SqlDataSource>
                    </div>
                    
                    <div id="users-options">
                        <table border="0">
                            <tr>
                                <td style="width: 100px;"><asp:Label ID="deleteLabel" runat="server" 
                                    Text="User Name:"></asp:Label></td>
                                <td style="width: 100px;"><asp:TextBox ID="deleteName" runat="server">
                                    </asp:TextBox></td>
                                <td style="width: 10px;">&nbsp;</td>
                                <td style="width: 100px;"><asp:Button ID="deleteButton" 
                                    OnClick="deleteButton_Click" Text="Delete User" runat="server" /></td>
                            </tr>
                            <tr><td style="height: 20px;">&nbsp;</td></tr>
                                <tr>
                                <td style="width: 100px;"><asp:Label ID="Label1" runat="server" Text="">
                                    </asp:Label></td>
                                <td style="width: 100px;"><asp:TextBox ID="adminName" runat="server">
                                    </asp:TextBox></td>
                                <td style="width: 10px;">&nbsp;</td>
                                <td style="width: 100px;"><asp:Button ID="adminButton" 
                                    OnClick="adminButton_Click" Text="Make Admin" runat="server" /></td>
                            </tr>
                        </table>
                    </div>
                </ContentTemplate>
            </asp:RoleGroup>
        </RoleGroups>
    </asp:LoginView>                       
</asp:Content>
<asp:Content ID="ContentUser" ContentPlaceHolderID="MasterContentUser" Runat="Server">
    <asp:LoginView ID="LoginViewUser" runat="server">
        <RoleGroups>
            <asp:RoleGroup Roles="user">
                <ContentTemplate>
                    Sorry, you do not have access to this page.
                </ContentTemplate>
            </asp:RoleGroup>
        </RoleGroups>
    </asp:LoginView>                       
</asp:Content>
<asp:Content ID="ContentAnonymous" ContentPlaceHolderID="MasterContentAnonymous" Runat="Server">
    <asp:LoginView ID="LoginViewAnonymous" runat="server">
        <AnonymousTemplate>
            Sorry, you do not have access to this page.
        </AnonymousTemplate>
    </asp:LoginView>                       
</asp:Content>